package com.woniu.controller;

import com.woniu.dto.DischargeApplyDTO;
import com.woniu.dto.InpatientDischargeAppDTO;
import com.woniu.entity.InpatientDischargeApp;
import com.woniu.service.InpatientDischargeAppService;
import com.woniu.utils.ResponseUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.text.ParseException;

@RestController
@RequestMapping("/inpatientDischargeApp")
public class InpatientDischargeAppController {
    @Resource
    private InpatientDischargeAppService service;
    //查看出院申请列表
    @PostMapping("/list")
    public ResponseUtil recordList(@RequestBody InpatientDischargeAppDTO inpatientDischargeAppDTO){
        ResponseUtil result = service.recordList(inpatientDischargeAppDTO);
        return result;
    }
    //添加出院申请记录
    @PostMapping("/add")
    public ResponseUtil addRecord(@RequestBody DischargeApplyDTO dto) throws ParseException {
        ResponseUtil result = service.addRecord(dto);
        return result;
    }
    @PutMapping("/{id}/{status}")
    public ResponseUtil updateStatus(@PathVariable Integer id,
                                     @PathVariable Integer status){
        InpatientDischargeApp app = new InpatientDischargeApp();
        app.setId(id);
        app.setOaStatus(status);
        ResponseUtil result = service.updateRecord(app);
        return result;
    }
}
